package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TProductWheel;
import com.ruoyi.system.service.ITProductWheelService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 轮对 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-02-20
 */
@Controller
@RequestMapping("/system/tProductWheel")
public class TProductWheelController extends BaseController
{
    private String prefix = "system/tProductWheel";
	
	@Autowired
	private ITProductWheelService tProductWheelService;
	
	@RequiresPermissions("system:tProductWheel:view")
	@GetMapping()
	public String tProductWheel()
	{
	    return prefix + "/tProductWheel";
	}
	
	/**
	 * 查询轮对列表
	 */
	@RequiresPermissions("system:tProductWheel:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(TProductWheel tProductWheel)
	{
		startPage();
        List<TProductWheel> list = tProductWheelService.selectTProductWheelList(tProductWheel);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出轮对列表
	 */
	@RequiresPermissions("system:tProductWheel:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TProductWheel tProductWheel)
    {
    	List<TProductWheel> list = tProductWheelService.selectTProductWheelList(tProductWheel);
        ExcelUtil<TProductWheel> util = new ExcelUtil<TProductWheel>(TProductWheel.class);
        return util.exportExcel(list, "tProductWheel");
    }
	
	/**
	 * 新增轮对
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存轮对
	 */
	@RequiresPermissions("system:tProductWheel:add")
	@Log(title = "轮对", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(TProductWheel tProductWheel)
	{		
		return toAjax(tProductWheelService.insertTProductWheel(tProductWheel));
	}

	/**
	 * 修改轮对
	 */
	@GetMapping("/edit/{planid}")
	public String edit(@PathVariable("planid") String planid, ModelMap mmap)
	{
		TProductWheel tProductWheel = tProductWheelService.selectTProductWheelById(planid);
		mmap.put("tProductWheel", tProductWheel);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存轮对
	 */
	@RequiresPermissions("system:tProductWheel:edit")
	@Log(title = "轮对", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(TProductWheel tProductWheel)
	{		
		return toAjax(tProductWheelService.updateTProductWheel(tProductWheel));
	}
	
	/**
	 * 删除轮对
	 */
	@RequiresPermissions("system:tProductWheel:remove")
	@Log(title = "轮对", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(tProductWheelService.deleteTProductWheelByIds(ids));
	}
	
}
